﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESOL.Common.Entity;
using ESOL.Business.Fa;

namespace ESOL.WinUI.Fa
{
    public partial class frmMaintainAssetTypeQuery : BaseForm.frmBaseDialogyQueryForm
    {
        #region Variable
        private FaAssetsTypeEntity mSelectedAssetType;
        public FaAssetsTypeEntity SelectedAssetType 
        {

            get { return mSelectedAssetType; }
        }
        #endregion

        #region Construction
        public frmMaintainAssetTypeQuery()
        {
            InitializeComponent();
        }
        #endregion

        #region Function
        private void BindTreeAssetType()
        {
            List<FaAssetsTypeEntity> list = FaAssetsTypeBs.GetFaAssetsTypeAllList();
            treeAssetType.DataSource = list;
            treeAssetType.ExpandAll();
        }
        #endregion

        #region Events
        private void frmMaintainAssetTypeQuery_Load(object sender, EventArgs e)
        {
            BindTreeAssetType();
        }

        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (mSelectedAssetType != null)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("请选择一个固定资产类别！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 
        private void treeDepartment_AfterFocusNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
        {
            mSelectedAssetType = FaAssetsTypeBs.GetFaAssetsTypeByID(e.Node.GetValue("AssetTypeId").ToString());
        }

        private void treeAssetType_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (SelectedAssetType != null)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("请选择一个固定资产类别！", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        #endregion


    }
}
